# -*- coding: utf-8 -*-
"""Public section, including homepage and signup."""
from flask import Blueprint, render_template, request, url_for
from flask_login import LoginManager, login_required, login_user, logout_user

from myflaskapp.user.models import User
from myflaskapp.extensions import login_manager

blueprint = Blueprint('public', __name__,
                      static_folder='../static', static_url_path='')

login_manager.login_view = 'login'


@login_manager.user_loader
def load_user(user_id):
    return User.query.get(int(user_id))


@blueprint.route('/')
def login():
    return render_template('index.html')


@blueprint.route('/home')
@login_required
def home():
    return render_template('home.html')
